using System.Collections.Generic;
using HarmonyLib;
using UnityEngine;

namespace TheWorldOfKongfuEasyMod;

[HarmonyPatch(typeof(gang_b12WugongTypeAttackArea))]
[HarmonyPatch("Load")]
public class Patch_gang_b12WugongTypeAttackArea_Load
{
    static bool Prefix(ref List<gang_b12WugongTypeAttackArea.Row> ___rowList, ref bool ___isLoaded, TextAsset csv)
    {
        if (Main.Setting._005isFixThroughSkill.Value)
        {
            ___rowList.Clear();
            List<string[]> list = CsvParser2.Parse(csv.text);
            for (int i = 1; i < list.Count; i++)
            {
                int num = 0;
                gang_b12WugongTypeAttackArea.Row row = new gang_b12WugongTypeAttackArea.Row
                {
                    ID = list[i][num++],
                    Name = list[i][num++],
                    Attackstyle = list[i][num++],
                    Area = list[i][num++],
                    Range = list[i][num++],
                    Space = list[i][num++]
                };
                if (row.Attackstyle == "A07")
                {
                    var area = Main.Setting._006fixThroughSkillDistance.Value.ToString("F0");
                    row.Area = area;
                    row.Range = area;
                }

                ___rowList.Add(row);
            }

            ___isLoaded = true;
            return false;
        }

        return true;
    }
}